<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content ">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            	<a href="javascript:;" class="btn btn-default" data-url="http://www.tp-shop.cn/Doc/Index/article/id/1014/developer/user.html" onclick="get_help(this)"><i class="fa fa-question-circle"></i> 帮助</a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 添加团购活动</h3>
                </div>
                <div class="panel-body ">   
                    <!--表单数据-->
                    <form method="post" id="handleposition" action="{:U('Admin/Promotion/groupbuyHandle')}">                    
                        <!--通用信息-->
                    <div class="tab-content col-md-10">                 	  
                        <div class="tab-pane active" id="tab_tongyong">                           
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td class="col-sm-2">团购标题：</td>
                                    <td class="col-sm-6">
                                        <input type="text" class="form-control" name="title" id="title" value="{$info.title}" >
                                        <span id="err_attr_name" style="color:#F00; display:none;"></span>                                        
                                    </td>
                                    <td class="col-sm-4">请填写团购标题</td>
                                </tr>
                                <tr>
                                    <td>开始时间：</td>
                                    <td>
                               			<input type="text" class="form-control" id="start_time" name="start_time" value="{$info.start_time}">
                                    </td>
                                    <td class="col-sm-4">团购开始时间</td>
                                </tr>                                
                                <tr>
                                    <td>结束时间：</td>
                                    <td>
                      					<input type="text" class="form-control" id="end_time" name="end_time" value="{$info.end_time}">   
                                    </td>
                                    <td class="col-sm-4">团购结束时间</td>
                                </tr>
                                  
                                <tr>
                                    <td>设置团购商品：</td>
                                    <td>
                                    	<div class="col-xs-9">
                             			<input type="text" id="goods_name" name="goods_name" class="form-control" value="{$info.goods_name}">
                             			</div>
                             			<div class="col-xs-3">
                             			<input type="hidden" id="goods_id" name="goods_id" value="{$info.goods_id}">
                             			<input class="btn btn-primary" type="button" onclick="selectGoods()" value="选择商品">
                             			</div>
                                    </td>
                                    <td class="col-sm-4">请选择加入团购的商品</td>
                                </tr>
                                <tr>
                                    <td>团购价格：</td>
                                    <td>
                                    	<div class="col-xs-4">
	                      					<input type="text" class="form-control" id="price" name="price" value="{$info.price}"  onpaste="this.value=this.value.replace(/[^\d.]/g,'')" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"/>
	                      					<input type="hidden" id="goods_price" name="goods_price" value="{$info.goods_price}">
                      					</div>
                      					<span id="price_html"></span>
                                    </td>
                                    <td class="col-sm-4">商品团购价格</td>
                                </tr>
                                <tr>
                                    <td>参团数量：</td>
                                    <td>
                      					<input type="text" class="form-control" id="goods_num" name="goods_num" value="{$info.goods_num}"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" />
                                    </td>
                                    <td class="col-sm-4">请填写自然数，参与团购的商品数量</td>
                                </tr> 
                                <tr>
                                    <td>虚拟购买数：</td>
                                    <td>
                      					<input type="text" class="form-control" name="virtual_num" value="{$info.virtual_num}"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')"/>
                                    </td>
                                    <td class="col-sm-4">虚拟已购买参团人数</td>
                                </tr>
                                <tr>
                                    <td>团购介绍：</td>
                                    <td>
                                    	<textarea class="form-control" rows="4" placeholder="请输入团购介绍" name="intro">{$info.intro}</textarea>
                                    </td>
                                    <td class="col-sm-4">团购描述介绍</td>
                                </tr>                                
                                </tbody> 
                                <tfoot>
                                	<tr>
                                	<td><input class="btn btn-default" type="reset" value="重置">
                                		<input type="hidden" name="act" value="{$act}">
                                		<input type="hidden" name="id" value="{$info.id}">
                                	</td>
                                	<td class="col-sm-4"></td>
                                	<td class="text-right"><input class="btn btn-primary" type="button" onclick="adsubmit()" value="保存"></td></tr>
                                </tfoot>                               
                                </table>
                        </div>                           
                    </div>              
			    	</form><!--表单数据-->
                </div>
            </div>
        </div>
    </section>
</div>
<script>

function adsubmit(){
	if($('#title').val() ==''){
		layer.msg('团购标题不能为空');return;
	}
	if($('#price').val() ==''){
		layer.msg('团购价格不能为空');return;
	}
	if($('#group_num').val() ==''){
		layer.msg('限购数量不能为空');return;
	}
	$('#handleposition').submit();
}

$(document).ready(function() {
	$('#start_time').daterangepicker({
		format:"YYYY-MM-DD HH:mm:ss",
		singleDatePicker: true,
		showDropdowns: true,
		minDate:'{$min_date}',
		maxDate:'2030-01-01',
		startDate:'{$min_date}',
		timePicker : true, //是否显示小时和分钟  
        timePickerIncrement:1,//time选择递增数
		timePicker12Hour : false, //是否使用12小时制来显示时间                
	    locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
	});
	
	$('#end_time').daterangepicker({
		format:"YYYY-MM-DD HH:mm:ss",
		singleDatePicker: true,
		showDropdowns: true,
		minDate:'{$min_date}',
		maxDate:'2030-01-01',
		startDate:'{$min_date}',
		timePicker : true, //是否显示小时和分钟  
        timePickerIncrement:1,//time选择递增数
		timePicker12Hour : false, //是否使用12小时制来显示时间                
	    locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
	});

});

function selectGoods(){
    var url = "{:U('Promotion/search_goods',array('tpl'=>'select_goods'))}";
    layer.open({
        type: 2,
        title: '选择商品',
        shadeClose: true,
        shade: 0.2,
        area: ['75%', '75%'],
        content: url, 
    });
}

function call_back(goods_id,goods_name,store_count){
	$('#goods_id').val(goods_id);
	$('#goods_name').val(goods_name);
	$('#group_num').val(store_count);
	layer.closeAll('iframe');
}
</script>
</body>
</html>